home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / pcv05n09.zip / SYSWIT.ZIP / PLANS.BAS < prev    next >
BASIC Source File  |  1992-01-17  |  5KB  |  184 lines

  1. DefInt A-Z
  2.  
  3. Sub Frame (F As Form, L, T, H, W, Style)
  4. F.DrawWidth = Style
  5. F.ForeColor = HiColor:  If Style = 2 Then F.ForeColor = LoColor
  6.  
  7.  'bottom:
  8. F.Line (L + F.DrawWidth, T + H + OffSet)-(L + W - F.DrawWidth, T + H + OffSet)
  9. 'right:
  10. F.Line (L + W + OffSet, T + F.DrawWidth)-(L + W + OffSet, T + H + OffSet - F.DrawWidth)
  11.  
  12.  
  13. F.ForeColor = LoColor: If Style = 2 Then F.ForeColor = HiColor
  14. 'top:
  15.  F.Line (L - BigOffSet + F.DrawWidth, T - BigOffSet)-(L + W + BigOffSet - F.DrawWidth, T - BigOffSet)
  16.  'left:
  17. F.Line (L - BigOffSet, T + F.DrawWidth - BigOffSet)-(L - BigOffSet, T + H + BigOffSet - F.DrawWidth)
  18.  
  19. End Sub
  20.  
  21. Sub CopyFile (Source As String)
  22. X = FALSE
  23. If UCase$(Source) = "SYSTEM.INI" Then X = MsgBox("Restart using current SYSTEM.INI?", 4, "No Change")
  24. If X = IDYES Then RestartProc
  25. If X = IDNO Then Exit Sub
  26. Destination$ = Windir + "\" + "System.ini"
  27. DestinationBack$ = Windir + "\" + "system.bak"
  28. Source$ = Windir + "\" + Source
  29. On Error Resume Next
  30. Kill DestinationBack$
  31. Name Destination$ As DestinationBack$
  32.  
  33. Open Source$ For Binary As #1
  34. whole = LOF(1) \ 32000
  35.  
  36. part = LOF(1) Mod 32000
  37. If whole + part = 0 Then MsgBox Source$ + " not found.": Close : GetProfile: Exit Sub
  38. buffer$ = String$(32000, 0)
  39. start& = 1
  40. Open Destination$ For Binary As #2
  41. On Error GoTo ErrProc
  42. For X = 1 To whole
  43.        Get #1, start&, buffer$
  44.        Put #2, start&, buffer$
  45.        start& = start& + 32000
  46. Next X
  47. buffer$ = String$(part, 0)
  48. Get #1, start&, buffer$
  49. Put #2, start&, buffer$
  50. Close
  51. Call RestartProc
  52. Exit Sub
  53.  
  54.  
  55. ErrProc:
  56. MsgBox "Disk error"
  57. Kill Destination$
  58. Name DestinationBack$ As Destination$
  59. End
  60. End Sub
  61.  
  62. Sub RestartProc ()
  63. Okay% = ExitWindows(&H42, 0)
  64. If Okay% = 0 Then MsgBox "Cannot Restart Windows", 32, "Win Restart"
  65. End
  66. End Sub
  67.  
  68. Function GetHighLight () As Integer
  69. For I = 0 To 4
  70. If FORM1.Option1(I).Value = TRUE Then GetHighLight = I
  71. Next I
  72. End Function
  73.  
  74. Sub Openfile (C As Control)
  75.    WorkingFileName = Windir + "\SYSWITCH.TXT"
  76.     OpenMode% = READFILE
  77.    FileNum% = Fileopener(WorkingFileName, OpenMode%, 0)
  78.    If FileNum% = 0 Then GoTo OpenErr
  79.   On Error GoTo OpenErr
  80.   If LOF(FileNum%) > 60000 Then
  81.     Msg$ = "Sorry your file is too large to edit."
  82.     MsgBox Msg$, 16, "File Too Big"
  83.     Exit Sub
  84.   End If
  85.   Do Until EOF(FileNum%)
  86.   Line Input #FileNum%, NextLine$
  87.     LineFromFile$ = LineFromFile$ + NextLine$ + Chr$(13) + Chr$(10)
  88.   Loop
  89. C.Text = LineFromFile$
  90. Close FileNum%
  91. Exit Sub
  92.  
  93. OpenErr:
  94. MsgBox "Problem reading " + WorkingFileName
  95. C.Text = "Couldn't read instructions file"
  96. Exit Sub
  97.  
  98. End Sub
  99.  
  100. Function Fileopener (NameToUse$, Mode%, RecordLen%) As Integer
  101.   Const READFILE = 2
  102.   FileNum% = FreeFile
  103.   On Error GoTo OpenerError
  104.   Open NameToUse For Input As FileNum%
  105.   Fileopener = FileNum%
  106.  Exit Function
  107.  
  108. OpenerError:
  109. Fileopener = 0
  110. Exit Function
  111. End Function
  112.  
  113. Sub CommandTest ()
  114.     Com$ = Command$
  115.     If Com$ = "" Then Exit Sub
  116. DirCheck:
  117.     Slash = InStr(Com$, "\")
  118.     If Slash = 0 Then GoTo DirGone
  119.     If Slash = Len(Com$) Then GoTo CommandError
  120.     Com$ = Mid$(Com$, Slash + 1)
  121.     GoTo DirCheck
  122. DirGone:
  123.     If Com$ = "" Then Exit Sub
  124.     If Len(Com$) > 12 Then GoTo CommandError
  125.     Period = InStr(Com$, ".")
  126.     If Period < 1 Or Period > 9 Then GoTo CommandError
  127.     If Len(Mid$(Com$, Period + 1)) > 3 Then GoTo CommandError
  128.     CopyFile (Com$)
  129.     Exit Sub
  130. CommandError:
  131. MsgBox Command$ + " is not a legal file name."
  132. Exit Sub
  133. End Sub
  134.  
  135. Sub RestartWIn ()
  136. For X = 0 To 4
  137. If FORM1.Option1(X).Value = TRUE Then SysFile$ = FileC(X + 1)
  138. Next X
  139. Call CopyFile(SysFile$)
  140. End Sub
  141.  
  142. Sub GetProfile ()
  143. ProfRead "ConfigName1", NameC(1)
  144. ProfRead "ConfigName2", NameC(2)
  145. ProfRead "ConfigName3", NameC(3)
  146. ProfRead "ConfigName4", NameC(4)
  147. ProfRead "ConfigName5", NameC(5)
  148. ProfRead "ConfigFile1", FileC(1)
  149. ProfRead "ConfigFile2", FileC(2)
  150. ProfRead "ConfigFile3", FileC(3)
  151. ProfRead "ConfigFile4", FileC(4)
  152. ProfRead "ConfigFile5", FileC(5)
  153. End Sub
  154.  
  155. Sub SaveProfile ()
  156. ProfSave "ConfigFile1", FileC(1)
  157. ProfSave "ConfigFile2", FileC(2)
  158. ProfSave "ConfigFile3", FileC(3)
  159. ProfSave "ConfigFile4", FileC(4)
  160. ProfSave "ConfigFile5", FileC(5)
  161. ProfSave "ConfigName1", NameC(1)
  162. ProfSave "ConfigName2", NameC(2)
  163. ProfSave "ConfigName3", NameC(3)
  164. ProfSave "ConfigName4", NameC(4)
  165. ProfSave "ConfigName5", NameC(5)
  166. End Sub
  167.  
  168. Sub ProfSave (Label$, Variable$)
  169. X = WritePrivateProfileString(App, Label$, Variable$, Ini)
  170. End Sub
  171.  
  172. Sub ProfRead (Desire$, Destination$)
  173. Default$ = "Default Configuration"
  174. If Mid$(Desire$, 7, 1) = "F" Then Default$ = "SYSTEM.INI"
  175. RLen = GetPrivateProfileString(App, Desire$, Default$, ReadString, 128, Ini)
  176. Destination$ = Left$(ReadString, RLen)
  177. End Sub
  178.  
  179. Sub CenterForm (F As Form)
  180. F.Left = (Screen.Width / 2) - (F.Width / 2)
  181. F.Top = (Screen.Height / 2) - (F.Height / 2)
  182. End Sub
  183.  
  184.